/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thienphuc.patient.dao.impl;

import java.util.Date;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import thienphuc.patient.dao.AbstractHibernateDaoSupport;
import thienphuc.patient.dao.NhapThuocDAO;
import thienphuc.patient.dto.NhapThuoc;
import thienphuc.patient.dto.NhapThuocId;
import thienphuc.patient.dto.Thuoc;

/**
 *
 * @author QuocDat
 */
public class NhapThuocDAOImpl extends AbstractHibernateDaoSupport<NhapThuoc, NhapThuocId> implements NhapThuocDAO {

    public NhapThuocDAOImpl(Class<NhapThuoc> classPersistent) {
        super(classPersistent);
    }

    public List<NhapThuoc> findByThuoc(Thuoc thuoc) throws Exception {
        return this.findByProperty(NHAP_THUOC_THUOC, thuoc);
    }

    public List<NhapThuoc> findByNgayNhap(Date ngayNhapStart, Date ngayNhapEnd) throws Exception {
        Criterion criterionNgayNhap = Restrictions.between(NHAP_THUOC_NGAY_NHAP, ngayNhapStart, ngayNhapEnd);
        return this.findByCriteria(criterionNgayNhap);
    }

    public List<NhapThuoc> findByTenCongTy(String tenCongTy) throws Exception {
        Criterion criterionTenCongTy = Restrictions.like(NHAP_THUOC_TEN_CONG_TY, "%" + tenCongTy + "%");
        return this.findByCriteria(criterionTenCongTy);
    }
}
